import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_applearnprogrom/http/httpbydio/HttpUtils.dart';
import 'package:flutter_applearnprogrom/utils/rsa_utils.dart';
import 'package:flutter_applearnprogrom/base/view.dart';
import 'package:shared_preferences/shared_preferences.dart';

class RegisterView extends StatefulWidget {
  @override
  _RegisterViewState createState() => _RegisterViewState();
}
//new MaterialButton(
//color: Colors.blue,
//textColor: Colors.white,
//child: new Text('点我'),
//onPressed: () {
//// ...
//},
//)
class _RegisterViewState extends State<RegisterView> {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      body: Center(
        child: Text('Hello Flutter'),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () async {
//          方法1
//        Response  response;
//        Dio dio=new  Dio();
//        response= await   dio.get("https://www.fastmock.site/mock/1010b262a743f0b06c565c7a31ee9739/root");
//        print(response.data.toString());
//        方法2
//        Response response;
//        Dio dio = new Dio();
//        response = await dio.get("/test", queryParameters: {"id": 12, "name": "wendu"});
//        print(response.data.toString());



          HttpController.getData("https://www.fastmock.site/mock/1010b262a743f0b06c565c7a31ee9739/root", (data){
            if(!mounted)return;
            setState(() {
              print(data["data"]);
              print(data["msg"]);
              print(data["code"]);
            });
          });

        },
//        child: Text('点击'),
      ),

    )
    ;
  }
}